Xi-Language Reference: Ordinary Differential Equations

    • ode_solve (Solving ordinary differential equations)

    ode_solve (Solving ordinary differential equations)

    Parameters

              ode_solve ( func, y, t, abs_tol = 1.0e-10, rel_tol = 1.0e-10 )
    
              Types: func                   Stmt
                     y                      double[]
                     t                      double[]
                     abs_tol                double[]
                     rel_tol                double
    

    Return

              double[]  (solution at desired points)
    

    Description

    ode_solve solves the initial value problem of first order ordinary differential equations.
          dy/dt = f(t,y) ,  or, in component form,
          dy(i)/dt = f(i) = f(i,t,y(1),y(2),...,y(neq)) (i = 1,...,neq).
     
    This function switches automatically between stiff and nonstiff methods. This means that the user does not have to determine whether the problem is stiff or not, and the solver will automatically choose the appropriate method. It always starts with the nonstiff method.

    Xi the the ordinary differential equation will be determined in a similar way like writing it down on a piece of paper. (y; t) -> y': y' = f (y,t) The vector y describes the initial values for y at the point t[0] and the vector t gives the desired values of the independent variable. The optional variable rel_tol is the relative tolerance parameter. Vector abs_tol gives the absolute tolerance parameter. The estimated local error in y[i] will be controlled so as to be less than

                  error[i] = rel_tol*abs(y[i]) + abs_tol[i]
     

    Example

     (  1)>t=interval(0,5,10);
     Function interval defined
     (  2)>y=ode_solve([ (y; t)->y' : y'=2*y*t+t*t*t; ], {-0.5}, t,\rel_tol=1e-14);
     (  3)>plot(t,y,\curve,\marker=4);
     (  4)>t=interval(0,2*~pi,100);
     (  5)>double[] f(double y[]) { return { y[1], -y[0] }; }
     Function f defined
     (  6)>y=ode_solve([ (y; t)->y' : y'=f(y);], {0,1}, t);
     (  7)>window(0,\clearAll);
     (  8)>plot(y[0,*], y[1,*],\curve);
     (  9)>u=replicate(x=interval(-1,1,9),10);
     ( 10)>velocity_field(-transpose(u), u, x, x);
     Function arrowHead defined
     Function velocity_field defined
     Function error defined
    

    Reference

    This function is based on the subroutine lsoda of ODEPACK.
     c authors..
     c                      linda r. petzold
     c                      applied mathematics division 8331
     c                      sandia national laboratories
     c                      livermore, ca 94550
     c and
     c                      alan c. hindmarsh,
     c                      mathematics and statistics division, l-316
     c                      lawrence livermore national laboratory
     c                      livermore, ca 94550.
     

    © 1995 by Bodo Junglas, Klaus Spanderen and Fabian Weis
    - Last revised: Wed Jun 19 16:58:32 1996